﻿<%@ WebHandler Language="C#" Class="userLogin" %>

using System;
using System.Web;
using System.Data;
using AMCBO;
using AMCOBJ;

public class userLogin : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        //context.Response.ContentType = "text/plain";
        //context.Response.Write("Hello World");
        users ObjUsers = new users();
        user UserBO = new user();
        if (!string.IsNullOrEmpty(context.Request.QueryString["user"]))
        {
            ObjUsers.UserEmail = context.Request.QueryString["user"].ToString();
        }
        if (!string.IsNullOrEmpty(context.Request.QueryString["pass"]))
        {
            ObjUsers.UserPassword = context.Request.QueryString["pass"].ToString();
        }
        
        DataTable dt = new DataTable();
        dt = UserBO.loginUser(ObjUsers);
        if (dt.Rows.Count>0)
        {
            HttpCookie username = new HttpCookie("username");
            HttpCookie userid = new HttpCookie("userid");
            HttpCookie user_name = new HttpCookie("user_name");
            username.Value = dt.Rows[0]["username"].ToString();
            userid.Value = dt.Rows[0]["user_id"].ToString();
            user_name.Value = dt.Rows[0]["user_name"].ToString();
            context.Response.Cookies.Add(userid);
            context.Response.Cookies.Add(username);
            context.Response.Cookies.Add(user_name);
            context.Response.Write("y");
        }
        else
        {
            context.Response.Write("n");
        }
        
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}